package com.itheima.springbootinit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class springbootcontroller {
    /*获取普通配置*/
    @Value("${name}")
    private String name;
    /*获取对象属性*/
    @Value("${person1.name}")
    private String name1;
    @Value("${person.age}")
    private Integer age;
    /*获取数组*/
    @Value("${address[0]}")
    private String address;
    /*获取纯量*/
    @Value("/${msg2}")
    private String msg1;

    /*通过environment获取*/
    @Autowired
    private Environment env;

    @Autowired
    private Person person;
    @RequestMapping("/hello")
    public String hello(){
       // System.out.println(name1);
      //  System.out.println(age);
       // System.out.println(env.getProperty("person1.name"));
        System.out.println(person.getName());
        System.out.println(person.getAge());
        System.out.println(person.getAddress()[0]);
        return "hello spring boot";

    }
}
